package org.clever.sharding.jdbc.aop;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Administrator on 2018/12/5.
 */
public class ShardingHolder {

    private static Logger log = LoggerFactory.getLogger(ShardingHolder.class);

    private static final ThreadLocal<Boolean> sharding = new ThreadLocal<>();

    public static Boolean getSharding() {
        if (sharding.get() == null) {
            return false;
        }
        return sharding.get();
    }

    static void setSharding() {
        log.debug("使用sharding功能");
        sharding.set(true);
    }

    static void clear() {
        log.debug("clear sharding");
        sharding.remove();
    }
}
